import { renderRoutes } from '@utils';
import routes from './config';

const appRoutes = async (dispatch) => {
  return Promise.all([
    // do Preload
    dispatch({
      type: 'SET_PRELOAD',
      payload: true
    })
  ]).then(() => {
    // set preload done
    const result = { allow: true };
    return result.allow ? renderRoutes(routes, process.env.APP_NAME) : null;
  });
};

export default appRoutes;
